<?php
/**
 * Created by PhpStorm
 * User: whh
 * Date: 2023/9/10
 * Time: 0:00
 */

namespace app\backstage\logic;


use app\common\model\QuickOpen;

class OpenLogic
{
    /**
     * 设置弹窗
     * @param $data
     * @param int $id
     * @return \think\response\Json
     * @Author: whh
     */
    public function setOpen($data,$id = 0)
    {
        $data['mini_pay_money'] = $data['mini_pay_money'] * 100;
        if (isset($data['quick_apps'])){
            $data['quick_apps'] = implode(',', $data['quick_apps']);
        }
        $data['novel_id'] = isset($data['table_novel_id']) && isset($data['table_novel_id'][0]) ? $data['table_novel_id'][0] : 0;
        if (!$id){
            $model = new QuickOpen();
        }else{
            $model = QuickOpen::get($id);
        }
        $model->allowField(true)->save($data);
        return sucJson();
    }
}